<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="../vue.js" type="text/javascript" charset="utf-8"></script>
        <!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
    </head>
    <body>
        <div id="app">
            <p>Original message: "{{ message }}"</p>
            <p>Computed reversed message1: "{{ reversedMessage }}"</p>
            <p>Computed reversed message2: "{{ reversedMessage }}"</p>
        </div>
        <script type="text/javascript">
            var app = new Vue({
                el: '#app',
                data: {
                    message: 'Hello'
                },
                computed: {
                    // 计算属性有缓存只执行一次，函数会执行多次
                    // 计算属性的 getter
                    reversedMessage: function () {
                        // `this` 指向 vm 实例
                        console.log("run reversedMessage");
                        return this.message.split('').reverse().join('')
                    }
                }
            })
        </script>
        <style type="text/css">
        </style>
    </body>
</html>